<!DOCTYPE html>
<html>
<head>
    <title>AZ-204 Question 148</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
            line-height: 1.6;
        }
        .question-container {
            border: 1px solid #ddd;
            padding: 20px;
            border-radius: 5px;
            margin-bottom: 20px;
        }
        .drag-drop-container {
            display: flex;
            gap: 20px;
            margin: 20px 0;
        }
        .source-options {
            width: 40%;
            padding: 15px;
            background-color: #f5f5f5;
            border-radius: 5px;
        }
        .option {
            padding: 10px;
            margin: 8px 0;
            background-color: white;
            border: 2px solid #0078d4;
            border-radius: 4px;
            cursor: move;
        }
        .target-table {
            width: 60%;
            border-collapse: collapse;
        }
        .target-table th, .target-table td {
            border: 1px solid #ddd;
            padding: 12px;
            text-align: left;
        }
        .target-table th {
            background-color: #f2f2f2;
        }
        .drop-zone {
            min-height: 40px;
            padding: 10px;
            border: 2px dashed #0078d4;
            background-color: white;
        }
        .answer-button {
            padding: 10px 15px;
            background-color: #0078d4;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }
        .answer-button:hover {
            background-color: #106ebe;
        }
        .answer {
            margin-top: 20px;
            padding: 20px;
            background-color: #e8f5e9;
            border-radius: 5px;
            display: none;
        }
        .correct-answer {
            font-weight: bold;
            color: #2e7d32;
        }
        .explanation {
            margin-top: 15px;
        }
    </style>
</head>
<body>
    <div class="question-container">
        <h2>QUESTION NO: 148 DRAG DROP</h2>
        <p>You develop a gateway solution for a public facing news API.</p>
        <p>The news API back end is implemented as a RESTful service and hosted in an Azure App Service instance.</p>
        <p>You need to configure back-end authentication for the API Management service instance.</p>
        <p>Which target and gateway credential type should you use? To answer, drag the appropriate values to the correct parameters. Each value may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.</p>
        <p><strong>NOTE:</strong> Each correct selection is worth one point.</p>
        
        <div class="drag-drop-container">
            <div class="source-options" id="sourceOptions">
                <div class="option" draggable="true" data-value="HTTP(s) endpoint">HTTP(s) endpoint</div>
                <div class="option" draggable="true" data-value="Basic">Basic</div>
                <div class="option" draggable="true" data-value="Client cert">Client cert</div>
                <div class="option" draggable="true" data-value="Managed identity">Managed identity</div>
                <div class="option" draggable="true" data-value="Azure Resource">Azure Resource</div>
            </div>
            
            <table class="target-table">
                <thead>
                    <tr>
                        <th>Configuration parameter</th>
                        <th>Value</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Target</td>
                        <td class="drop-zone" id="targetDrop"></td>
                    </tr>
                    <tr>
                        <td>Gateway credentials</td>
                        <td class="drop-zone" id="credentialsDrop"></td>
                    </tr>
                </tbody>
            </table>
        </div>
        
        <button class="answer-button" id="showAnswer">查看答案</button>
        
        <div class="answer" id="answer">
            <h3>正确答案:</h3>
            <div class="correct-answer">
                <p><strong>Target:</strong>Azure Resource</p>
                <p><strong>Gateway credentials:</strong> Client cert</p>
            </div>
            <div class="explanation">
                <h4>说明:</h4>
                <p>1. <strong>Target 应选择 "Azure Resource":</strong></p>
                <ul>
                    <li>题目中后端服务托管在Azure App Service实例中，属于Azure资源</li>
                    <li>图片中明确列出了"Azure Resource"作为可选项</li>
                    <li>当后端是Azure原生服务时，选择Azure Resource比HTTP(s) endpoint更符合最佳实践</li>
                </ul>
                
                <p>2. <strong>Gateway credentials 应选择 "Client cert":</strong></p>
                <ul>
                    <li>Basic认证是API Management与后端服务集成的常见方式</li>
                    <li>Client cert更适合需要双向SSL认证的高级场景，图片中显示Client cert是有效的凭据类型选项</li>
                    <li>Managed identity适用于需要Azure AD身份验证的场景</li>
                    <li>题目没有提到需要证书或高级身份验证要求</li>
                </ul>
                
                <p>Box 1: Azure Resource
                    题目中提到的后端服务是托管在Azure App Service中的RESTful服务。在Azure API Management中配置后端认证时，如果后端是Azure托管的服务（如App Service），应该选择"Azure Resource"作为目标类型。这是因为Azure Resource会自动处理Azure平台内的身份验证集成。
                    
                    Box 2: Client cert
                    对于公共新闻API的网关解决方案，使用客户端证书(Client cert)是最合适的网关凭证类型。这是因为：
                    
                    1.客户端证书提供了比基本认证(Basic)更高的安全性
                    2.它适合公共API场景，可以验证调用者的身份
                    3.RESTful服务通常使用基于证书的认证
                    4.题目没有提到需要用户级别的认证(这可能需要OAuth等)，所以客户端证书是最佳选择
                    基本认证(Basic)虽然也可以使用，但在公共API场景中不够安全，而题目中也没有提到需要用户凭据。
                    
                    因此，正确的配置应该是：
                    
                    目标(Target): Azure Resource
                    网关凭证(Gateway credentials): Client cert</p>
            </div>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const options = document.querySelectorAll('.option');
            const dropZones = document.querySelectorAll('.drop-zone');
            const showAnswerBtn = document.getElementById('showAnswer');
            const answerDiv = document.getElementById('answer');
            
            let draggedItem = null;
            
            // Drag events for options
            options.forEach(option => {
                option.addEventListener('dragstart', function() {
                    draggedItem = this;
                    setTimeout(() => {
                        this.style.opacity = '0.4';
                    }, 0);
                });
                
                option.addEventListener('dragend', function() {
                    this.style.opacity = '1';
                });
            });
            
            // Drop events for zones
            dropZones.forEach(zone => {
                zone.addEventListener('dragover', function(e) {
                    e.preventDefault();
                    this.style.backgroundColor = '#d4e6ff';
                });
                
                zone.addEventListener('dragleave', function() {
                    this.style.backgroundColor = 'white';
                });
                
                zone.addEventListener('drop', function(e) {
                    e.preventDefault();
                    this.style.backgroundColor = 'white';
                    
                    // Remove from any other zone
                    dropZones.forEach(z => {
                        if (z !== this && z.textContent === draggedItem.textContent) {
                            z.textContent = '';
                            z.style.minHeight = '40px';
                        }
                    });
                    
                    // Add to this zone
                    this.textContent = draggedItem.textContent;
                    this.style.minHeight = 'auto';
                    this.setAttribute('data-value', draggedItem.getAttribute('data-value'));
                });
            });
            
            // Show answer button
            showAnswerBtn.addEventListener('click', function() {
                answerDiv.style.display = 'block';
            });
        });
    </script>
</body>
</html>
